package ru.gerunn;

import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.hibernate.Session;

import ru.gerunn.hibernate.tables.Ht;
import ru.gerunn.hibernate.util.HibernateUtil;

public class Main {

	public static void main(String[] args) throws ParseException {
		System.out.println("Helloe!!");
		
		Session session = HibernateUtil.getSessionFactory().openSession();
		 
		session.beginTransaction();
		
		long currentTime = new Date().getTime();
		Timestamp currentTimestamp = new Timestamp(currentTime);
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSS");
		long anyTime = simpleDateFormat.parse("2012-12-01-01.02.03.123").getTime();
		Timestamp anyTimestamp = new Timestamp(anyTime);
		
		Ht ht = new Ht();
		ht.setString("string");
		ht.setAnyTimestamp(anyTimestamp);
		
		session.save(ht);
		session.getTransaction().commit();
	}

}
